

var app = new Vue({
  el: "#app",
  data: {
    city: '',
    weatherList: []
  },
  methods: {
    searchWeather: function () {
      // console.log('天气查询');
      // console.log(this.city);

      //保存this

      var that = this;

      axios.get('https://restapi.amap.com/v3/weather/weatherInfo?key=bfa77be10e4119076fee50c105fb7465&city=' + this.city)
        .then(function (res) {
          console.log(res.data.lives);
          that.weatherList = res.data.lives;
        }, function (err) {
          console.log(err);
        })
    },
    changeCity: function (city) {
      this.city = city;
      this.searchWeather();
    }
  }

})